Skip to content

fix(backend): type prisma singleton globals correctly#724

Merged
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
samueloyibodevv:fix/653-prisma-global-typing
Jun 1, 2026
Merged

fix(backend): type prisma singleton globals correctly#724
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
samueloyibodevv:fix/653-prisma-global-typing

Conversation

@samueloyibodevv
Copy link
Copy Markdown
Contributor

@samueloyibodevv samueloyibodevv commented Jun 1, 2026

Overview

This PR fixes the typing on the Prisma hot-reload singleton in backend/src/lib/prisma.ts. The global cache now correctly marks prisma and pool as optional, which matches the existing if (!...) initialization logic and removes the small type lie without changing runtime behavior.

Related Issue

Closes #653

Changes

🔧 Prisma singleton typing

  • [MODIFY] backend/src/lib/prisma.ts
  • Changed the global singleton annotation so both cached properties are optional:
    • prisma?: PrismaClient
    • pool?: pg.Pool
  • Kept the existing singleton pattern intact.
  • Preserved the current || fallback and if (!...) initialization checks.

Verification Results

Acceptance Criteria Status
prisma and pool are typed as optional
Build still passes
Singleton runtime behavior remains unchanged

How to Test

# 1. Confirm you're on the branch
git branch --show-current

# 2. Verify the backend builds successfully
npm run build

# 3. Optional: inspect the typing change
git diff -- backend/src/lib/prisma.ts

Screenshots

✅ Backend build passes

Run:

npm run build
image

Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean — closes #653 (prisma singleton globals now typed properly, no any cast). all CI green. merging!

join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

@ogazboiz ogazboiz merged commit 9af645e into LabsCrypt:main Jun 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Replace globalThis cast in lib/prisma.ts with proper typing

2 participants